package lesson01;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestText {
    public static void main(String[] args) {
        new MyFrame1();
    }
}
class MyFrame1 extends Frame {
    public MyFrame1(){
        TextField textField = new TextField();
        add(textField);
        //监听这个文本框输入的文字
        MyActionListener myActionListener = new MyActionListener();
        textField.addActionListener(myActionListener);
        //设置转换编码
        textField.setEchoChar('*');
        setVisible(true);
        pack();
    }
}
class MyActionListener implements ActionListener {
    @Override
    public void actionPerformed(ActionEvent e) {
        TextField textField = (TextField) e.getSource();
        System.out.println(textField.getText());
        textField.setText("");
    }
}
